/**
 * @file uart+adc.c
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2024-03-11
 *
 * @copyright Copyright (c) 2024
 *
 */
#include "test.h"
#include <stdio.h>


extern UART_HandleTypeDef huart1;
int fputc(int c, FILE *stream) {
  HAL_UART_Transmit(&huart1, (unsigned char *)&c, 1, 1000);
  return 1;
}

extern ADC_HandleTypeDef hadc1;
void tst_adc_entry() {
  HAL_Delay(100);
  // uint16_t ADC_num = HAL_ADC_GetValue(&hadc1); //??ADC????

  // float ADC_V = 3.3 * ADC_num / 4096; //???????(????????3.3V)

  // printf("adc=%f", ADC_V);

  GPIO_PinState tmp = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13);
  tmp = !tmp;
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, tmp);
}

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
  /* Prevent unused argument(s) compilation warning */
  UNUSED(htim);

  /* NOTE : This function should not be modified, when the callback is needed,
            the HAL_TIM_PeriodElapsedCallback could be implemented in the user
     file
   */
  GPIO_PinState tmp = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13);
  tmp = !tmp;
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, tmp);
}